package com.et.core.store

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import io.reactivex.Completable
import io.reactivex.Flowable

interface BaseDao

@Dao
interface IFileDao : BaseDao {

    @Query("SELECT * FROM table_file")
    fun all(): Flowable<MutableList<FileEntity>>

    @Insert(onConflict = OnConflictStrategy.REPLACE, entity = FileEntity::class)
    fun insert(fileEntity: FileEntity): Completable

    @Query("DELETE FROM table_file WHERE id in (:ids)")
    fun deleteById(ids: Int): Int

    @Query("DELETE FROM table_file WHERE file_status in (:status)")
    fun deleteByStatus(status: Int = FileEntity.STATUS_DELETE): Int

    @Query("DELETE FROM table_file")
    fun deleteAll(): Completable
}